home *** CD-ROM | disk | FTP | other *** search
/ Delphi Developer's Kit 1996 / Delphi Developer's Kit 1996.iso / power / myvcs / myvcs.pas < prev    next >
Pascal/Delphi Source File  |  1995-12-22  |  5KB  |  202 lines

  1. library MyVCS;
  2.  
  3. uses
  4.   Forms,
  5.   SysUtils,
  6.   Classes,
  7.   Dialogs,
  8.   WinTypes,
  9.   WinProcs,
  10.   VirtIntf,
  11.   ToolIntf,
  12.   VCSIntf,
  13.   MyVcsAbt in 'MYVCSABT.PAS' {AboutBox},
  14.   MyVcsInf in 'MYVCSINF.PAS' {MyVCSInfo},
  15.   MyVcsOpn in 'MYVCSOPN.PAS' {VCSOpenForm};
  16.  
  17. type
  18.   TMyVCSClient = class(TIVCSClient)
  19.   public
  20.     function GetIDString: string; override;
  21.     procedure ExecuteVerb(Index: Integer); override;
  22.     function GetMenuName: string; override;
  23.     function GetVerb(Index: Integer): string; override;
  24.     function GetVerbCount: Integer; override;
  25.     function GetVerbState(Index: Integer): Word; override;
  26.     procedure ProjectChange; override;
  27.   end;
  28.  
  29. var
  30.     WindowHandle: HWnd;
  31.     TempStr : String;
  32.  
  33. const
  34.     MyVCSClient: TMyVCSClient = nil;
  35.     ToolInterface: TIToolServices = nil;
  36.  
  37. procedure OpenAFile;
  38. begin
  39.     if ToolInterface <> nil then
  40.     begin
  41.         VCSOpenForm := TVCSOpenForm.Create (Application);
  42.         VCSOpenForm.ShowModal;
  43.         if VCSOpenForm.ModalResult = idOK then
  44.         begin
  45.             TempStr := VCSOpenForm.Label4.Caption + '\' + VCSOpenForm.Edit1.Text;
  46.             if not ToolInterface.OpenFile (TempStr) then
  47.                 MessageDlg ('Could not open ' + VCSOpenForm.Edit1.Text, mtWarning, [mbOK], 0);
  48.         end;
  49.         VCSOpenForm.Destroy;
  50.     end;
  51. end;
  52.  
  53. procedure ShowVCSAboutBox;
  54. begin
  55.     AboutBox := TAboutBox.Create (Application);
  56.     AboutBox.ShowModal;
  57.     AboutBox.Destroy;
  58. end;
  59.  
  60. procedure ShowVCSFormCount;
  61. var
  62.     i : Integer;
  63. begin
  64.     if ToolInterface <> nil then
  65.     begin
  66.         i := ToolInterface.GetFormCount;
  67.         TempStr := Format ('Form Count: %d', [i]);
  68.         MessageDlg (TempStr, mtInformation, [mbOK], 0);
  69.     end;
  70. end;
  71.  
  72. procedure ShowVCSUnitCount;
  73. var
  74.     i : Integer;
  75. begin
  76.     if ToolInterface <> nil then
  77.     begin
  78.         i := ToolInterface.GetUnitCount;
  79.         TempStr := Format ('Unit Count: %d', [I]);
  80.         MessageDlg (TempStr, mtInformation, [mbOK], 0);
  81.     end;
  82. end;
  83.  
  84. procedure CloseVCSCurrentProject;
  85. begin
  86.     if ToolInterface <> nil then
  87.     begin
  88.         TempStr := ToolInterface.GetProjectName;
  89.         if TempStr <> '' then
  90.             if MessageDlg ('Close project ' + TempStr + '?', mtConfirmation, mbOKCancel, 0) = idOK then
  91.                 if not ToolInterface.CloseProject then
  92.                     MessageDlg ('Could not close ' + TempStr + '!', mtInformation, [mbOK], 0);
  93.     end;
  94. end;
  95.  
  96. procedure CloseVCSCurrentFile;
  97. begin
  98.     if ToolInterface <> nil then
  99.     begin
  100.         TempStr := ToolInterface.GetCurrentFile;
  101.         if TempStr <> '' then
  102.             if MessageDlg ('Close file ' + TempStr + '?', mtConfirmation, mbOKCancel, 0) = idOK then
  103.                 if not ToolInterface.CloseFile (TempStr) then
  104.                     MessageDlg ('Could not close ' + TempStr + '!', mtInformation, [mbOK], 0);
  105.     end;
  106. end;
  107.  
  108. procedure ShowVCSInfo;
  109. var
  110.     i : Integer;
  111. begin
  112.     if ToolInterface <> nil then
  113.     begin
  114.         MyVCSInfo := TMyVCSInfo.Create(Application);
  115.         MyVCSInfo.Edit1.Text := ToolInterface.GetProjectName;
  116.         if ToolInterface.GetUnitCount > 0 then
  117.             for i := 0 to ToolInterface.GetUnitCount - 1 do
  118.                 MyVCSInfo.UnitListBox.Items.Add (ToolInterface.GetUnitName(i));
  119.         if ToolInterface.GetFormCount > 0 then
  120.             for i := 0 to ToolInterface.GetFormCount - 1 do
  121.                 MyVCSInfo.FormListBox.Items.Add (ToolInterface.GetFormName(i));
  122.         MyVCSInfo.ShowModal;
  123.         MyVCSInfo.Destroy;
  124.     end;
  125. end;
  126.  
  127. function TMyVCSClient.GetIDString: String;
  128. begin
  129.     result := 'Cervasio.Vcs';
  130. end;
  131.  
  132. procedure TMyVCSClient.ExecuteVerb(Index: Integer);
  133. begin
  134.     Case Index of
  135.         0 : ShowVCSInfo;
  136.         1 : OpenAFile;
  137.         2 : ShowVCSFormCount;
  138.         3 : ShowVCSUnitCount;
  139.         5 : CloseVCSCurrentProject;
  140.         6 : CloseVCSCurrentFile;
  141.         8 : ShowVCSAboutBox;
  142.     end;
  143. end;
  144.  
  145. function TMyVCSClient.GetVerb(Index: Integer): string;
  146. begin
  147.     case Index of
  148.         0 : result := 'Project &Info...';
  149.         1 : result := '&Open File...';
  150.         2 : result := '&Form Count...';
  151.         3 : result := '&Unit Count...';
  152.         4 : result := '';
  153.         5 : result := 'Close Current &Project';
  154.         6 : result := '&Close Current File';
  155.         7 : result := '';
  156.         8 : result := '&About MyVCS...';
  157.     end;
  158. end;
  159.  
  160. function TMyVCSClient.GetVerbCount: Integer;
  161. begin
  162.     result := 9;
  163. end;
  164.  
  165. function TMyVCSClient.GetVerbState(Index: Integer): Word;
  166. begin
  167.     result := vsEnabled;
  168. end;
  169.  
  170. procedure TMyVCSClient.ProjectChange;
  171. begin
  172.     if ToolInterface <> nil then
  173.     begin
  174.         { handle anything needed when the project changes }
  175.     end;
  176. end;
  177.  
  178. function TMyVCSClient.GetMenuName: String;
  179. begin
  180.     result := '&Workgroup';
  181. end;
  182.  
  183.  
  184. function MyVCSInit (VCSInterface: TIToolServices): TIVCSClient; export;
  185. begin
  186.     ToolInterface := VCSInterface;
  187.     if ToolInterface <> nil then
  188.     begin
  189.         MyVCSClient := TMyVCSClient.Create;
  190.         WindowHandle := VCSInterface.GetParentHandle;
  191.         result := MyVCSClient;
  192.     end
  193.     else
  194.         result := nil;
  195. end;
  196.  
  197. exports
  198.     MyVCSinit name VCSManagerEntryPoint resident;
  199.  
  200. begin
  201. end.
  202.